import { minCache } from '@/utils/min-cache'
export const uploadFilePromise = ({ filePath, baseUrl = '/common/upload', name = 'file' }) => {
  let action = `${process.env.VUE_APP_API_URL}${baseUrl}`
  //#ifdef H5
  if (process.env.NODE_ENV === 'development') {
    action = `/api${baseUrl}`
  } else {
    action = `${baseUrl}`
  }
  //#endif
  return new Promise((resolve, reject) => {
    uni.uploadFile({
      url: action, // 仅为示例，非真实的接口地址
      filePath,
      name,
      formData: {},
      header: {
        Authorization: `Bearer ${minCache.get('ut')}`,
      },
      success: (res) => {
        resolve(JSON.parse(res.data))
      },
    })
  })
}
